home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / www / src / WWW / Library / Implementation / HTAnchor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-20  |  9.0 KB  |  305 lines

  1. /*                 /Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTAnchor.html
  2.  */
  3.  
  4. /*      Hypertext "Anchor" Object                                    HTAnchor.h
  5. **      ==========================
  6. **
  7. **      An anchor represents a region of a hypertext document which is linked
  8. **      to another anchor in the same or a different document.
  9. */
  10.  
  11. #ifndef HTANCHOR_H
  12. #define HTANCHOR_H
  13.  
  14. /* Version 0 (TBL) written in Objective-C for the NeXT browser */
  15. /* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independant */
  16.  
  17. #include "HTList.h"
  18. #include "HTAtom.h"
  19.  
  20. #ifdef SHORT_NAMES
  21. #define HTAnchor_findChild                      HTAnFiCh
  22. #define HTAnchor_findChildAndLink               HTAnFiLi
  23. #define HTAnchor_findAddress                    HTAnFiAd
  24. #define HTAnchor_delete                         HTAnDele
  25. #define HTAnchor_makeLastChild                  HTAnMaLa
  26. #define HTAnchor_parent                         HTAnPare
  27. #define HTAnchor_setDocument                    HTAnSeDo
  28. #define HTAnchor_document                       HTAnDocu
  29. #define HTAnchor_setFormat                      HTAnSeFo
  30. #define HTAnchor_format                         HTAnForm
  31. #define HTAnchor_setIndex                       HTAnSeIn
  32. #define HTAnchor_isIndex                        HTAnIsIn
  33. #define HTAnchor_address                        HTAnAddr
  34. #define HTAnchor_hasChildren                    HTAnHaCh
  35. #define HTAnchor_title                          HTAnTitl
  36. #define HTAnchor_setTitle                       HTAnSeTi
  37. #define HTAnchor_appendTitle                    HTAnApTi
  38. #define HTAnchor_link                           HTAnLink
  39. #define HTAnchor_followMainLink                 HTAnFoMa
  40. #define HTAnchor_followTypedLink                HTAnFoTy
  41. #define HTAnchor_makeMainLink                   HTAnMaMa
  42. #define HTAnchor_setProtocol                    HTAnSePr
  43. #define HTAnchor_protocol                       HTAnProt
  44. #define HTAnchor_physical                       HTAnPhys
  45. #define HTAnchor_setPhysical                    HTAnSePh
  46. #define HTAnchor_methods                        HtAnMeth
  47. #endif
  48.  
  49. /*                      Main definition of anchor
  50. **                      =========================
  51. */
  52.  
  53. typedef struct _HyperDoc HyperDoc;  /* Ready for forward references */
  54. typedef struct _HTAnchor HTAnchor;
  55. typedef struct _HTParentAnchor HTParentAnchor;
  56.  
  57. /*      After definition of HTFormat: */
  58. #include "HTFormat.h"
  59.  
  60. typedef HTAtom HTLinkType;
  61.  
  62. typedef struct {
  63.   HTAnchor *    dest;           /* The anchor to which this leads */
  64.   HTLinkType *  type;           /* Semantics of this link */
  65. } HTLink;
  66.  
  67. struct _HTAnchor {              /* Generic anchor : just links */
  68.   HTLink        mainLink;       /* Main (or default) destination of this */
  69.   HTList *      links;          /* List of extra links from this, if any */
  70.   /* We separate the first link from the others to avoid too many small mallocs
  71.      involved by a list creation. Most anchors only point to one place. */
  72.   HTParentAnchor * parent;      /* Parent of this anchor (self for adults) */
  73. };
  74.  
  75. struct _HTParentAnchor {
  76.   /* Common part from the generic anchor structure */
  77.   HTLink        mainLink;       /* Main (or default) destination of this */
  78.   HTList *      links;          /* List of extra links from this, if any */
  79.   HTParentAnchor * parent;      /* Parent of this anchor (self) */
  80.  
  81.   /* ParentAnchor-specific information */
  82.   HTList *      children;       /* Subanchors of this, if any */
  83.   HTList *      sources;        /* List of anchors pointing to this, if any */
  84.   HyperDoc *    document;       /* The document within which this is an anchor */
  85.   char *        address;        /* Absolute address of this node */
  86.   HTFormat      format;         /* Pointer to node format descriptor */
  87.   BOOL          isIndex;        /* Acceptance of a keyword search */
  88.   char *        title;          /* Title of document */
  89.  
  90.   HTList*       methods;        /* Methods available as HTAtoms */
  91.   void *        protocol;       /* Protocol object */
  92.   char *        physical;       /* Physical address */
  93. };
  94.  
  95. typedef struct {
  96.   /* Common part from the generic anchor structure */
  97.   HTLink        mainLink;       /* Main (or default) destination of this */
  98.   HTList *      links;          /* List of extra links from this, if any */
  99.   HTParentAnchor * parent;      /* Parent of this anchor */
  100.  
  101.   /* ChildAnchor-specific information */
  102.   char *        tag;            /* Address of this anchor relative to parent */
  103. } HTChildAnchor;
  104.  
  105.  
  106. /*      Create new or find old sub-anchor
  107. **      ---------------------------------
  108. **
  109. **      This one is for a new anchor being edited into an existing
  110. **      document. The parent anchor must already exist.
  111. */
  112.  
  113. extern HTChildAnchor * HTAnchor_findChild
  114.   PARAMS(
  115.      (HTParentAnchor *parent,
  116.       CONST char *tag)
  117.   );
  118.  
  119. /*      Create or find a child anchor with a possible link
  120. **      --------------------------------------------------
  121. **
  122. **      Create new anchor with a given parent and possibly
  123. **      a name, and possibly a link to a _relatively_ named anchor.
  124. **      (Code originally in ParseHTML.h)
  125. */
  126. extern HTChildAnchor * HTAnchor_findChildAndLink
  127.   PARAMS((
  128.       HTParentAnchor * parent,  /* May not be 0 */
  129.       CONST char * tag,         /* May be "" or 0 */
  130.       CONST char * href,        /* May be "" or 0 */
  131.       HTLinkType * ltype        /* May be 0 */
  132.   ));
  133.  
  134.  
  135. /*      Create new or find old named anchor
  136. **      -----------------------------------
  137. **
  138. **      This one is for a reference which is found in a document, and might
  139. **      not be already loaded.
  140. **      Note: You are not guaranteed a new anchor -- you might get an old one,
  141. **      like with fonts.
  142. */
  143.  
  144. extern HTAnchor * HTAnchor_findAddress
  145.   PARAMS(
  146.      (CONST char * address)
  147.      );
  148.  
  149.  
  150. /*      Delete an anchor and possibly related things (auto garbage collection)
  151. **      --------------------------------------------
  152. **
  153. **      The anchor is only deleted if the corresponding document is not loaded.
  154. **      All outgoing links from parent and children are deleted, and this anchor
  155. **      is removed from the sources list of all its targets.
  156. **      We also try to delete the targets whose documents are not loaded.
  157. **      If this anchor's source list is empty, we delete it and its children.
  158. */
  159.  
  160. extern BOOL HTAnchor_delete
  161.   PARAMS(
  162.      (HTParentAnchor *me)
  163.      );
  164.  
  165.  
  166. /*              Move an anchor to the head of the list of its siblings
  167. **              ------------------------------------------------------
  168. **
  169. **      This is to ensure that an anchor which might have already existed
  170. **      is put in the correct order as we load the document.
  171. */
  172.  
  173. extern void HTAnchor_makeLastChild
  174.   PARAMS(
  175.      (HTChildAnchor *me)
  176.      );
  177.  
  178. /*      Data access functions
  179. **      ---------------------
  180. */
  181.  
  182. extern HTParentAnchor * HTAnchor_parent
  183.   PARAMS(
  184.      (HTAnchor *me)
  185.      );
  186.  
  187. extern void HTAnchor_setDocument
  188.   PARAMS(
  189.      (HTParentAnchor *me, HyperDoc *doc)
  190.      );
  191.  
  192. extern HyperDoc * HTAnchor_document
  193.   PARAMS(
  194.      (HTParentAnchor *me)
  195.      );
  196. /* We don't want code to change an address after anchor creation... yet ?
  197. extern void HTAnchor_setAddress
  198.   PARAMS(
  199.      (HTAnchor *me, char *addr)
  200.      );
  201. */
  202.  
  203. /*      Returns the full URI of the anchor, child or parent
  204. **      as a malloc'd string to be freed by the caller.
  205. */
  206. extern char * HTAnchor_address
  207.   PARAMS(
  208.      (HTAnchor *me)
  209.      );
  210.  
  211. extern void HTAnchor_setFormat
  212.   PARAMS(
  213.      (HTParentAnchor *me, HTFormat form)
  214.      );
  215.  
  216. extern HTFormat HTAnchor_format
  217.   PARAMS(
  218.      (HTParentAnchor *me)
  219.      );
  220.  
  221. extern void HTAnchor_setIndex
  222.   PARAMS(
  223.      (HTParentAnchor *me)
  224.      );
  225.  
  226. extern BOOL HTAnchor_isIndex
  227.   PARAMS(
  228.      (HTParentAnchor *me)
  229.      );
  230.  
  231. extern BOOL HTAnchor_hasChildren
  232.   PARAMS(
  233.      (HTParentAnchor *me)
  234.      );
  235.  
  236. /*      Title handling
  237. */
  238. extern CONST char * HTAnchor_title
  239.   PARAMS(
  240.      (HTParentAnchor *me)
  241.      );
  242.  
  243. extern void HTAnchor_setTitle
  244.   PARAMS(
  245.      (HTParentAnchor *me, CONST char * title)
  246.      );
  247.  
  248. extern void HTAnchor_appendTitle
  249.   PARAMS(
  250.      (HTParentAnchor *me, CONST char * title)
  251.      );
  252.  
  253. /*      Link this Anchor to another given one
  254. **      -------------------------------------
  255. */
  256.  
  257. extern BOOL HTAnchor_link
  258.   PARAMS(
  259.      (HTAnchor *source, HTAnchor *destination, HTLinkType *type)
  260.      );
  261.  
  262. /*      Manipulation of links
  263. **      ---------------------
  264. */
  265.  
  266. extern HTAnchor * HTAnchor_followMainLink
  267.   PARAMS(
  268.      (HTAnchor *me)
  269.      );
  270.  
  271. extern HTAnchor * HTAnchor_followTypedLink
  272.   PARAMS(
  273.      (HTAnchor *me, HTLinkType *type)
  274.      );
  275.  
  276. extern BOOL HTAnchor_makeMainLink
  277.   PARAMS(
  278.      (HTAnchor *me, HTLink *movingLink)
  279.      );
  280.  
  281. /*      Read and write methods
  282. **      ----------------------
  283. */
  284. extern HTList * HTAnchor_methods PARAMS((HTParentAnchor *me));
  285.  
  286. /*      Protocol
  287. **      --------
  288. */
  289. extern void * HTAnchor_protocol PARAMS((HTParentAnchor * me));
  290. extern void HTAnchor_setProtocol PARAMS((HTParentAnchor * me,
  291.                                         void* protocol));
  292.  
  293. /*      Physical address
  294. **      ----------------
  295. */
  296. extern char * HTAnchor_physical PARAMS((HTParentAnchor * me));
  297. extern void HTAnchor_setPhysical PARAMS((HTParentAnchor * me,
  298.                                         char * protocol));
  299.  
  300. #endif /* HTANCHOR_H */
  301.  
  302. /*
  303.  
  304.     */
  305.